title="order-detail"
url = '/test951753/:slug|orderdetail-\d+.html$'
layout="default"

[session]
security = "user"
redirect = "account/login"
==

use Jason\Ccshop\Models\OrderStatus;
use GuzzleHttp\Client;

function onStart() {
header("Content-type: text/html; charset=utf-8");
$userid_login = $this['user']['attributes']['id'];
$slugArr = explode('-', str_replace('.html', '', $this->param('slug')));
$sn = $slugArr['1'];
$this['sn'] = $sn;

$order = App::make('Jason\Ccshop\Controllers\Orders')->orderDetail($sn);
$userid_order = $order['attributes']['uid'];
if($order == null){
return redirect('/account/login.html');
}
if($userid_order != $userid_login){
return redirect('/account/login.html');
}
$this['orderStatusCode'] = $order->order_status->code;

$this['order'] = $order;
dump($order);
}
==

<div class="address_content">
    <!-- breadcrumbs -->
    <div class="breadcrumbs">
        <div class="container">
            <ul>
                <li class="fl" ><a href="/">HCLOSET</a></li>
                <li class="fl" >お買物履歴詳細</li>
            </ul>
        </div>
    </div>
    <!-- breadcrumbs end -->
    <div class="orderCont">
        <div class="container">
            <h2 class="pageHead1">お買物履歴詳細</h2>
            <div class="ov dashboardBox">
                <div class="fl d_sidemenus">
                    {% partial 'account/left-bar' %}
                </div>
                <div class="fr d_main">
                    <div class="main-ttl">お買物履歴詳細</div>
                    <div class="detailBox orderBox">
                        <div class="detail_date">
                            <div class="history-status">{{ ('jason.ccshop::lang.order.status.' ~ orderStatusCode)|trans }}</div>
                            <div class="data-header">
                                <div class="date orderday">注文日：{{ order.created_at }}</div>
                            </div>
                            <table class="purchase-data" width="100%">
                                <thead>
                                <tr>
                                    <th>注文番号</th>
                                    <th>ご請求金額</th>
                                    <th>お支払い方法</th>
                                    <th>配送方法</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr>
                                    <td>{{ order.sn }}</td>
                                    <td>{{ order.total_price|formatPriceNotRate }}</td>
                                    <td>{{ order.payment.name }}</td>
                                    <td>{{ order.shippingmethod.name }}</td>
                                </tr>
                                </tbody>
                            </table>
                            <p class="cautions">
                                ※コンビニ前払い、Pay-easy（ATM・ネットバンキング払い）の場合は、「<a href="#settlement" class="colrBlue" shape="rect">お支払い方法</a>」でお客様番号などをご確認ください。
                            </p>
                            <table class="purchase-items" width="100%">
                                <caption>ご注文商品</caption>
                                <thead>
                                <tr>
                                    <th>商品名</th>
                                    <th>単価<span>（税抜）</span></th>
                                    <th>数量</th>
                                    <th>小計<span>（税抜）</span></th>
                                </tr>
                                </thead>
                                <tbody>
                                {% for orderPro in order.products %}
                                {% set condition = { 'id': orderPro.product_id } %}
                                {% set product = catalog.product(condition) %}
                                <tr>
                                    <td>
                                        <div class="item-data">
                                            <a href="" class="colrBlue" shape="rect">
                                                <div class="item-name">{{ product.name }}</div>
                                                <div class="item-standard">
                                                    {% for keyoption, option in orderPro.options %}
                                                    {{ keyoption }}:
                                                    {% for key, optionvalue in option %}
                                                    {{optionvalue}}
                                                    {% endfor %}
                                                    <br clear="none">
                                                    {% endfor %}
                                                </div>
                                            </a>
                                        </div>
                                    </td>
                                    <td class="nowordbeak">{{ orderPro.price|formatPriceNotRate }}</td>
                                    <td rowspan="1">{{ orderPro.qty }}</td>
                                    <td class="nowordbeak">{{ (orderPro.price * orderPro.qty)|formatPriceNotRate }}</td>
                                </tr>
                                {% endfor %}
                                </tbody>
                            </table>
                            {% if order.cart %}
                            <table class="purchase-result" width="100%">

                                <tbody>
                                <tr>
                                    <th>数量合計</th>
                                    <td>{{ order.cart.totalQty }}点</td>
                                </tr>
                                <tr>
                                    <th>商品合計<span>（税抜）</span></th>
                                    <td>{{ order.cart.sumProductPrice|formatPrice }}</td>
                                </tr>
                                {% if order.cart.promoAmount %}
                                <tr>
                                    <th>値引き</th>
                                    <td>－{{ order.cart.promoAmount|formatPrice }}</td>
                                </tr>
                                {% endif %}
                                <tr>
                                    <th>送料</th>
                                    <td>{{ order.cart.freight|formatPrice }}</td>
                                </tr>

                                <tr>
                                    <th>消費税合計</th>
                                    <td>{{ order.cart.tax|formatPrice }}</td>
                                </tr>
                                <tr>
                                    <th style="font-weight:bold;">合計</th>
                                    <td style="font-weight:bold;">{{ order.cart.totalPrice|formatPrice }}</td>
                                </tr>
                                {% if order.cart.points %}
                                <tr>
                                    <th>ご利用ポイント</th>
                                    <td>{{ order.cart.points }}ポイント<br clear="none"><span>（－{{ order.cart.points.amount|format }}）</span>
                                    </td>
                                </tr>
                                {% endif %}
                                <tr>
                                    <th>ご請求金額</th>
                                    <td>{{ order.cart.totalPrice |formatPrice }}</td>
                                </tr>

                                </tbody>
                            </table>
                            {% endif %}
                            <div>
                            </div>
                        </div>
                        <div class="detail_txt">
                            <div class="users-informations goInquiryBox">
                                <div class="ttl">お問い合わせ</div>
                                <div class="onBigBtn goInquiryBox_show">
                                    <img src="{{ 'assets/img/btn-inquiry-open.png'|theme }}" alt="" class="mr-auto">
                                </div>
                                <div class="goInquiryBox">
                                    <div class="new-inquiry">
                                        <p class="lead">ご注文内容についてご要望他、お問い合わせがございましたら、ご入力の上、送信してください。</p>
                                        <div class="skin-minimal">
                                            <table width="100%">
                                                <tbody>
                                                <tr>
                                                    <th colspan="1" rowspan="1" >お問い合わせ項目</th>
                                                    <td colspan="1" rowspan="1" class="icon" ><img height="20" alt="必須" width="44" src="{{ 'assets/img/icon-must.gif'|theme }}"></td>
                                                    <td colspan="1" rowspan="1" class="input-element">
                                                        <div class="iradio_box">
                                                            <label>
                                                                <div class="iradio_minimal">
                                                                    <input type="radio" name="indexForm1" value="1" title="性別" style="">
                                                                    <ins class="iCheck-helper" style=""></ins>
                                                                </div>商品について
                                                            </label>
                                                            <label>
                                                                <div class="iradio_minimal">
                                                                    <input type="radio" name="indexForm1" value="1" title="性別" style="">
                                                                    <ins class="iCheck-helper" style=""></ins>
                                                                </div>ご注文について
                                                            </label>
                                                            <label>
                                                                <div class="iradio_minimal">
                                                                    <input type="radio" name="indexForm1" value="1" title="性別" style="">
                                                                    <ins class="iCheck-helper" style=""></ins>
                                                                </div>配送について
                                                            </label>
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <th colspan="1" rowspan="1" >お問い合わせ内容</th>
                                                    <td colspan="1" rowspan="1" class="icon" ><img height="20" alt="必須" width="44" src="{{ 'assets/img/icon-must.gif'|theme }}"></td>
                                                    <td colspan="1" rowspan="1" class="input-element">
                                                        <textarea name="" class="registInquiryBody" title="お問い合わせ内容" placeholder="さらに問い合わせる" rows="10"></textarea>
                                                        <p class="ex">（4000文字以内）</p>
                                                    </td>
                                                </tr>

                                                </tbody>
                                            </table>
                                            <div class="onBigBtn">
                                                <a href=""><img src="{{ 'assets/img/btn-inquiry-send.png'|theme }}" alt=""></a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="users-informations">
                                <div class="ttl">お客様情報</div>
                                <table class="detailTable1">
                                    <tbody>
                                    <tr>
                                        <th colspan="1" rowspan="1">お名前</th>
                                        <td colspan="1" rowspan="1">{{ order.firstname }}</td>
                                    </tr>
                                    <tr>
                                        <th colspan="1" rowspan="1">お名前（フリガナ）</th>
                                        <td colspan="1" rowspan="1">{{ order.lastname }}</td>
                                    </tr>
                                    <tr>
                                        <th colspan="1" rowspan="1">メールアドレス</th>
                                        <td colspan="1" rowspan="1">{{ order.email }}</td>
                                    </tr>
                                    <tr>
                                        <th colspan="1" rowspan="1">電話番号</th>
                                        <td colspan="1" rowspan="1">{{ order.phonenumber }}</td>
                                    </tr>
                                    <tr>
                                        <th colspan="1" rowspan="1">住所</th>
                                        <td colspan="1" rowspan="1">〒{{ order.postcode }} {{ order.state.name }} {{ order.city }} {{order.address }}</td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                            <div class="users-informations">
                                <div class="ttl">お届け先</div>
                                <table class="detailTable1">
                                    <tbody>
                                    <tr>
                                        <th colspan="1" rowspan="1">お名前</th>
                                        <td colspan="1" rowspan="1">{{ order.firstname }}</td>
                                    </tr>
                                    <tr>
                                        <th colspan="1" rowspan="1">お名前（フリガナ）</th>
                                        <td colspan="1" rowspan="1">{{ order.lastname }}</td>
                                    </tr>
                                    <tr>
                                        <th colspan="1" rowspan="1">お届け先電話番号</th>
                                        <td colspan="1" rowspan="1">{{ order.phonenumber }}</td>
                                    </tr>
                                    <tr>
                                        <th colspan="1" rowspan="1">住所</th>
                                        <td colspan="1" rowspan="1">〒{{ order.postcode }} {{ order.state.name }} {{ order.city }} {{order.address }}</td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                            <div class="users-informations">
                                <div class="ttl">お支払い方法</div>
                                <table class="detailTable1">
                                    <tbody>
                                    <tr>
                                        <td colspan="1" rowspan="1">{{ order.payment.name }}</td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                            <div class="users-informations">
                                <div class="ttl">ポイントをためる・利用する</div>
                                <table class="detailTable1">
                                    <tbody>
                                    <tr>
                                        <th colspan="1" rowspan="1">ポイントカード</th>
                                        <td colspan="1" rowspan="1">利用なし</td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                            <div class="users-informations">
                                <div class="ttl">配送方法</div>
                                <table class="detailTable1">
                                    <tbody>
                                    <tr>
                                        <th colspan="1" rowspan="1">{{ order.shippingmethod.name }}</th>
                                        <td colspan="1" rowspan="1">
                                            お届け日：{{ order.shippingmethod.delivery_time }}
                                            <br>
                                            {% if orderStatusCode == 'delivery' %}
                                                {% set bill_no = catalog.getOrderBillno(order.id) %}
                                                伝票番号：
                                                {% if bill_no is not null %}
                                                    {% for val in bill_no %}
                                                    {{ val|trim }}
                                                    <a href="
                                                    {% if starts_with( val|trim , 'EA') or starts_with( val|trim , 'LX')%}
                                                        https://trackings.post.japanpost.jp/services/srv/search/direct?searchKind=S004&locale=ja&reqCodeNo1={{val|trim}}
                                                    {% elseif val|trim|slice(0,1) in [1,3,4,5,6,7,8,9]%}
                                                        http://www.cn.dhl.com/zh/express/tracking.html?AWB={{val|trim}}&brand=DHL
                                                    {% elseif starts_with( val|trim , '2')%}http://www.ydhexpress.com/Client/Show1.aspx?Source={{val|trim}}&Code=ydh&side=sh
                                                    {% endif %}" class="colrBlue">配達状況を見る</a>
                                                    {% endfor %}
                                                {% endif %}
                                            {% endif %}

                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>